package com.hugang.principle.singleresponsibility;

/**
 * 单一职责原则示例
 * 方案2：
 *  1、遵守单一职责原则
 *  2、但是改动很大，即类要分解，同时客户端代码有修改
 *  3、改进：直接修改Vehicle类，改动的代码会比较少 --> 方案3
 * @author hg
 * @date 2020/9/6 10:48
 */
public class SingleResponsibilityDemo2 {

    public static void main(String[] args) {
        RoadVehicle vehicle = new RoadVehicle();
        vehicle.run("摩托车");
        vehicle.run("汽车");

        AirVehicle airVehicle = new AirVehicle();
        airVehicle.run("飞机");
    }
}

class RoadVehicle {
    public void run(String vehicle) {
        System.out.println(vehicle + "在路上跑。");
    }
}

class AirVehicle {
    public void run(String vehicle) {
        System.out.println(vehicle + "在天上飞。");
    }
}
